/**
 * @Description： the implemented class for interface IRmoGrantService
 * @author： 20155872 游宇
 * @createTime: 2018-12-03 11:06 PM
 **/

package com.scb.dev.mms.service.impl;

import com.scb.dev.mms.common.DataCommon;
import com.scb.dev.mms.common.ResponseResult;
import com.scb.dev.mms.common.StatusCode;
import com.scb.dev.mms.dao.RmoGrantMapper;
import com.scb.dev.mms.service.IRmoGrantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: RmoGrantServiceImpl
 * @Description: the implemented class for interface IRmoGrantService
 * @author: YouYu 游宇
 * @createTime: 2018-12-03 11:06 PM
 **/
@Slf4j
@Service
public class RmoGrantServiceImpl implements IRmoGrantService {
    @Autowired
    private RmoGrantMapper rmoGrantMapper;

    @Override
    public ResponseResult selectMenuIdByRoleId(String roleId) {
        ResponseResult responseResult=new ResponseResult();
        List<String> muneList = new ArrayList<>();
        try{
           muneList= rmoGrantMapper.selectMenuIdByRoleId(roleId);
           responseResult=ResponseResult.responseResult(muneList,true,"getMenuIdByRoleId success!", StatusCode.OPERATIONSUCCESS,DataCommon.ICON_SUCCESS);
        }catch (NullPointerException e){
            responseResult=ResponseResult.responseResult(muneList,false,"getMenuIdByRoleId failed! NullPointException!", StatusCode.FINDNULL, DataCommon.ICON_ERROR);
            log.info("selectMenuByRoleId failed,NullPointerException");
            e.printStackTrace();
        }catch(Exception e){
            responseResult=ResponseResult.responseResult(muneList,false,"getMenuIdByRoleId failed! Unexpected Exception!", StatusCode.EXCEPTIONERROR,DataCommon.ICON_ERROR);
            log.info("selectMenuByRoleId failed,unknown Exception");
            e.printStackTrace();
        }
        return responseResult;
    }



}
